package games.swingPlus;

import utils.RandomNumber;
import graphics.Bitmap2D;
import hardware.Display2D;

public class Storage extends Bitmap2D{

	
public static final short WEIGHT_COLOR_RED		= 0x00f;	
public static final short WEIGHT_COLOR_BLUE		= 0xf00;	
public static final short WEIGHT_COLOR_GREEN	= 0x0f0;	
public static final short WEIGHT_COLOR_YELLOW	= 0x0fF;	
public static final short WEIGHT_COLOR_ORANGE	= 0x03e;	
	
	
	
public Storage() {
//	super(Display2D.getColumnCount(), 2);
	super(8, 2);
	// TODO Auto-generated constructor stub
}



public void init()
{
	int xCounter;
	int yCounter;
	
	short color;

	for (yCounter=0;yCounter<2;yCounter++)
		for (xCounter=0;xCounter<Display2D.getColumnCount();xCounter++)
			{
			color= getRandom();
			this.setPixel(xCounter, yCounter, color);
			
			}	
}




private short getRandom()
{
	short color;
	int value;
	
	value = RandomNumber.getRange(5);
	switch (value)
		{
		case 0:
			color=WEIGHT_COLOR_RED;
			break;
			
		case 1:
			color=WEIGHT_COLOR_BLUE;
			break;
			
		case 2:
			color=WEIGHT_COLOR_GREEN;
			break;
			
		case 3:
			color=WEIGHT_COLOR_YELLOW;
			break;
			
		case 4:
			color=WEIGHT_COLOR_ORANGE;
			break;
			
		default :
			color=0xfff;
			break;
		}
	
	return(color);
}

public void draw() 
{
	Display2D.display2DBitmap(0, 6, this);
}

	

	
public short pop(int xPos)
{
	short returnValue;

	
	returnValue=getPixel(xPos, 0);
	setPixel(xPos, 0,getPixel(xPos, 1));
	
	setPixel(xPos, 1,getRandom());
	
	return(returnValue);
	
}



	
}
